namespace yiCommerce.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class statuses_support : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.StatusPictures",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        StatusId = c.Int(nullable: false),
                        PictureId = c.Int(nullable: false),
                        DisplayOrder = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Statuses", t => t.StatusId, cascadeDelete: true)
                .ForeignKey("dbo.Pictures", t => t.PictureId, cascadeDelete: true)
                .Index(t => t.StatusId)
                .Index(t => t.PictureId);
            
            CreateTable(
                "dbo.Statuses",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CreatedAt = c.DateTime(nullable: false),
                        Text = c.String(),
                        CustomerId = c.Int(nullable: false),
                        Deleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Customer", t => t.CustomerId, cascadeDelete: true)
                .Index(t => t.CustomerId);
            
            CreateTable(
                "dbo.Comments",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CreatedAt = c.DateTime(nullable: false),
                        Text = c.String(),
                        StatusId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Statuses", t => t.StatusId, cascadeDelete: true)
                .Index(t => t.StatusId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Comments", new[] { "StatusId" });
            DropIndex("dbo.Statuses", new[] { "CustomerId" });
            DropIndex("dbo.StatusPictures", new[] { "PictureId" });
            DropIndex("dbo.StatusPictures", new[] { "StatusId" });
            DropForeignKey("dbo.Comments", "StatusId", "dbo.Statuses");
            DropForeignKey("dbo.Statuses", "CustomerId", "dbo.Customer");
            DropForeignKey("dbo.StatusPictures", "PictureId", "dbo.Pictures");
            DropForeignKey("dbo.StatusPictures", "StatusId", "dbo.Statuses");
            DropTable("dbo.Comments");
            DropTable("dbo.Statuses");
            DropTable("dbo.StatusPictures");
        }
    }
}
